package com.bdqn.t313.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * 异常处理切面类
 */
@Component
@Aspect
public class ErrorLogger {


    /**
     * 异常抛出增强
     * @param jp
     * @param ex
     */
    @AfterThrowing(pointcut = "execution(public int save())",throwing = "ex")
    public void afterThrowing(JoinPoint jp,RuntimeException ex){
        System.out.println(jp.getSignature().getName()+"方法抛出异常："+ex);
    }

}
